import request from '@/utils/request'

export function getTodoTaskPage(query) {
  return request({
    url: '/bpm/task/todo-page',
    method: 'get',
    params: query
  })
}

export function getDoneTaskPage(query) {
  return request({
    url: '/bpm/task/done-page',
    method: 'get',
    params: query
  })
}

export function completeTask(data) {
  return request({
    url: '/bpm/task/complete',
    method: 'PUT',
    data: data
  })
}

export function approveTask(data) {
  return request({
    url: '/bpm/task/approve',
    method: 'PUT',
    data: data
  })
}

export function rejectTask(data) {
  return request({
    url: '/bpm/task/reject',
    method: 'PUT',
    data: data
  })
}
export function backTask(data) {
  return request({
    url: '/bpm/task/back',
    method: 'PUT',
    data: data
  })
}

export function updateTaskAssignee(data) {
  return request({
    url: '/bpm/task/update-assignee',
    method: 'PUT',
    data: data
  })
}

export function getTaskListByProcessInstanceId(processInstanceId) {
  return request({
    url: '/bpm/task/list-by-process-instance-id?processInstanceId=' + processInstanceId,
    method: 'get',
  })
}

export function getNodeList(taskId) {
  return request({
    url: `/bpm/task/getBackNodes/${taskId}`,
    method: 'get',
  })
}

export function doBack(data){
  return request({
    url: '/bpm/task/doBack',
    method: 'post',
    data: data
  })
}

export function doBackDist(data){
  return request({
    url: '/bpm/task/doBackDist',
    method: 'post',
    data: data
  })
}

//是否可以批量审批
export function getBatchApprovalStatus(data) {
  return request({
    url: '/bpm/task/getBatchApprovalStatus',
    method: 'post',
    data: data
  })
}

//批量审批
export function getBatchApprovalDetail(data) {
  return request({
    url: '/bpm/process-instance/getBatchApprovalDetail',
    method: 'post',
    data: data
  })
}

//批量审批 同意
export function batchApprove(data) {
  return request({
    url: '/bpm/task/batchApprove',
    method: 'put',
    data: data
  })
}

// 批量审批 不通过
export function batchReject(data) {
  return request({
    url: '/bpm/task/batchReject',
    method: 'put',
    data: data
  })
}

//批量审批 转办
export function batchAssignee(data) {
  return request({
    url: '/bpm/task/batch-update-assignee',
    method: 'put',
    data: data
  })
}

//批量删除 批量驳回节点到起点或上一节点
export function batchDoBackDist(data) {
  return request({
    url: '/bpm/task/batchDoBackDist',
    method: 'post',
    data: data
  })
}

//批量抄送
export function batchCarbonCopy(data) {
  return request({
    url: '/bpm/task/batch-carbon-copy',
    method: 'post',
    data: data
  })
}